<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    *{
        margin: 0;
        padding: 0;
    }    
    h1{
        text-align: center;
        font-size: 24px;
        line-height: 40px;
        color: rgb(117, 75, 75);
    }
    .warp{
        margin: 0 auto;
        width: 600px;
        height: 400px;
        border: 10px solid rgb(101, 123, 223);
    }
    #app-chatroom{
        width: 600px;
        height: 200px;
        overflow-y: auto;
        border-bottom: 10px solid rgb(101, 123, 223);
    }
    </style>
</head>
<body>
    <h1>聊天室</h1>
    <div class="warp">
        <div id="app-chatroom"></div>
        <label for="txt">说点什么：</label>
        <input type="text" name="txt" id="say">
        <label for="send">发送</label>
        <input type="button" value="发送" id="sendBtn" name="send">
    </div>
</body>
<script src="./client.js"></script>
<script>
    function sendMessage(){
        ws.send(say.value);
        say.value = '';
    }
    document.onkeyup = (e)=>{
        if(e.keyCode == 13){
            sendMessage();
        }
    }
    sendBtn.onclick = ()=>{
        sendMessage();
    }
</script>
</html>